/*
 * @Description:
 * @Author: 龙春雨
 * @Date: 2023-04-06 14:07:24
 */
import 'babel-polyfill';
import 'classlist-polyfill';
import Vue from 'vue';
import axios from './router/axios';
import VueAxios from 'vue-axios';
import App from './App';
// import zhLocale from './lang/zh';
import './permission'; // 权限
import './error'; // 日志
import './cache'; //页面缓冲
import router from './router/router';
import store from './store';
import { loadStyle, downBlobFile, uploadChange } from './util';
import { validatenull } from './util/validate';
import { base64Encrypt } from './util/encryption';
import * as urls from '@/config/env';
import { iconfontUrl } from '@/config/env';
import * as filters from './filters'; // 全局filter
import ElementUI from 'element-ui';
import 'element-ui/packages/theme-chalk/src/index.scss';
import PwdTipIndex from '@/components/pwdTip';
import './environmentConfig.js';

import './styles/common.scss';
import crudMixins from '@/mixins/crudSetting';
window.$crudMixins = crudMixins;
import AvueFormDesign from 'pig-avue-form-design';
import AvueUeditor from '@/components/avue-plugin-ueditor';
import { quillEditor } from 'vue-quill-editor';
import basicContainer from './components/basic-container/main';
import BMapAddressSelect from './components/BMapAddressSelect';
// 字典数据组件
import DictResolver from '@/components/DictResolver';
// 字典标签组件
import DictTag from '@/components/DictTag';

// 挂载常用全局方法，import 引入
Vue.prototype.validatenull = validatenull;
Vue.prototype.downBlobFile = downBlobFile;
Vue.prototype.base64Encrypt = base64Encrypt;
Vue.prototype.$uploadChange = uploadChange;

DictResolver.install();

// 插件 json 展示
Vue.use(router);
// 表单设计器
Vue.use(AvueFormDesign);

window.axios = axios;
Vue.use(VueAxios, axios);

// eslint-disable-next-line no-undef
// Vue.use(AVUE, {
//   qiniu: {
//     AK: process.env.VUE_APP_AK, // 七牛云相关密钥
//     SK: process.env.VUE_APP_SK, // 七牛云相关密钥
//     bucket: process.env.VUE_APP_QINIU_URL, // 七牛云地址
//     scope: process.env.VUE_APP_BUCKET, // 存储空间名称
//     url: process.env.VUE_APP_UPLOAD_API, // 外链的域名地址
//   },
// });
// Vue.user(AvueUeditor);
Vue.use(ElementUI, {
  size: 'small',
  menuType: 'text',
});
// eslint-disable-next-line
// Vue.use(AVUE, {
//   locale: zhLocale,
//   size: 'small',
//   menuType: 'text',
// });

Vue.prototype.$uploadSizeError = (error, { fileSize }) => {
  if (error === '文件太大不符合') {
    Vue.prototype.$message.error(`文件大小不能超过${fileSize / 1024}M`);
  }
};

// 修改ElementUI 个别组件默认的设置

ElementUI.Dialog.props.closeOnClickModal.default = false; //是否可以通过点击 modal 关闭 Dialog
ElementUI.Dialog.props.closeOnPressEscape.default = false; // 是否可以通过按下 ESC 关闭 Dialog

ElementUI.DatePicker.props.defaultTime = {
  default() {
    if (this._props.value instanceof Array) {
      return ['00:00:00', '23:59:59'];
    }
    return '23:59:59';
  },
};

// 注册全局容器
Vue.component('basicContainer', basicContainer);
Vue.component('DictTag', DictTag);
Vue.component('BMapAddressSelect', BMapAddressSelect);
Vue.component('PwdTipIndex', PwdTipIndex);
Vue.component('avueUeditor', AvueUeditor);
Vue.component('quillEditor', quillEditor);

// 加载相关url地址
Object.keys(urls).forEach((key) => {
  Vue.prototype[key] = urls[key];
});

// 加载过滤器
Object.keys(filters).forEach((key) => {
  Vue.filter(key, filters[key]);
});

// 动态加载阿里云字体库
iconfontUrl.forEach((ele) => {
  loadStyle(ele);
});

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount('#app');
